<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>activate (UsersController)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File users_controller.rb, line 213</span>
        <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">activate</span>
                <span class="ruby-identifier">logout_keeping_session!</span>
                <span class="ruby-identifier">user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">find_by_activation_code</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:activation_code</span>]) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:activation_code</span>].<span class="ruby-identifier">blank?</span>
                <span class="ruby-keyword kw">case</span>
                <span class="ruby-keyword kw">when</span> (<span class="ruby-operator">!</span><span class="ruby-identifier">params</span>[<span class="ruby-identifier">:activation_code</span>].<span class="ruby-identifier">blank?</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">user</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">user</span>.<span class="ruby-identifier">active?</span>
                  <span class="ruby-identifier">user</span>.<span class="ruby-identifier">activate!</span>
                  <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:notice</span>] = <span class="ruby-value str">&quot;Signup complete! Please sign in to continue.&quot;</span>
                  <span class="ruby-identifier">redirect_to</span> <span class="ruby-value str">'/login'</span>
                <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:activation_code</span>].<span class="ruby-identifier">blank?</span>
                  <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:error</span>] = <span class="ruby-value str">&quot;The activation code was missing.  Please follow the URL from your email.&quot;</span>
                  <span class="ruby-identifier">redirect_back_or_default</span>(<span class="ruby-value str">'/'</span>)
                <span class="ruby-keyword kw">else</span> 
                  <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:error</span>]  = <span class="ruby-value str">&quot;We couldn't find a user with that activation code -- check your email? Or maybe you've already activated -- try signing in.&quot;</span>
                  <span class="ruby-identifier">redirect_back_or_default</span>(<span class="ruby-value str">'/'</span>)
                <span class="ruby-keyword kw">end</span>
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>